////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file   CollabRCBotUnitTests\TestDivisionTreeNode.h
///
/// @brief  Defines the tests for CollabRC::Bot::AI::DivisionOperationTreeNode
////////////////////////////////////////////////////////////////////////////////////////////////////

#include <cxxtest/TestSuite.h>
#include "../CollabRCBot/DivisionOperationTreeNode.h"
#include "../CollabRCBot/exceptions.h"
#include "MockConstantTreeNode.h"
#include "MockOperationTreeNode.h"

class TestDivisionOperationTreeNode : public CxxTest::TestSuite
{
private:
    MockConstantTreeNode m_lhs, m_rhs;
    MockOperationTreeNode m_op;
public:
    TestDivisionOperationTreeNode():m_lhs(8),m_rhs(4),m_op(m_lhs, m_rhs) { }

    virtual void setUp()
    {
        m_lhs.SetValue(8);
        m_rhs.SetValue(4);
    }

    /**
     * @brief Tests the calculation done
     * @version $Id$
     * @author Matthew P. Del Buono
     */
    void TestPerformOperation()
    {
        CollabRC::Bot::AI::DivisionOperationTreeNode division(m_lhs, m_rhs);
        TS_ASSERT_EQUALS(division.PerformOperation(8.0f, 4.0f), 2.0f);
        TS_ASSERT_EQUALS(division.PerformOperation(-8.0f, 4.0f), -2.0f);
        TS_ASSERT_EQUALS(division.PerformOperation(-8.0f, -4.0f), 2.0f);
        TS_ASSERT_EQUALS(division.PerformOperation(8.0f, -4.0f), -2.0f);

        TS_ASSERT_EQUALS(division.PerformOperation(0.0f, 1.0f), 0.0f);

        TS_ASSERT_THROWS(division.PerformOperation(1.0f, 0.0f), const CollabRC::Bot::AI::IllegalOperationException&);
        TS_ASSERT_THROWS(division.PerformOperation(0.0f, 0.0f), const CollabRC::Bot::AI::IllegalOperationException&);

    }

    /**
     * @brief Tests the clone operation
     */
    void TestClone()
    {
        CollabRC::Bot::AI::DivisionOperationTreeNode division(m_lhs, m_rhs);
        CollabRC::Bot::AI::ComputationalTreeNode* clone = division.Clone();
        TS_ASSERT_EQUALS(clone->Compute(), division.Compute());
        TS_ASSERT_THROWS_NOTHING(delete clone);
    }

    /**
     * Tests the ability to clone from another operation
     */
    void TestMutate()
    {
        
    }
};